/**   
 * @Title: SportteryFootballAgp.java 
 * @Package com.esun.rabbit2.viewer.mainact.lotteryhallact 
 * @Description: TODO(竞彩足球ActivityGroup) 
 * @Description: (竞彩足球ActivityGroup) 
 * @author: City Jiangsy@500wan.com   
 * @date: 2011-8-12 上午10:32:09  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.cheetah.view.personal.sportlotteryfootball;

import java.util.Calendar;
import java.util.Hashtable;

import android.app.ActivityGroup;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.ImageButton;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;
import android.widget.Toast;

import com.esun.cheetah.R;
import com.esun.cheetah.biz.personal.personalinfo.UserInfo;
import com.esun.cheetah.config.Config;
import com.esun.cheetah.view.personal.LoginAct;
import com.esun.cheetah.view.personal.lotteryrecord.LotteryRecordAgp;
import com.esun.util.log.EDebug;

/**
 * 
 * @Package 
 *          com.esun.cheetah.view.personal.sportlotteryfootball.SportteryFootballAgp
 * @ClassName: SportteryFootballAgp
 * @Description: TODO(football lottery activity group)
 * @author handy <br/>
 * @date create at 2012-7-31 下午2:54:47
 * 
 */
public class SportteryFootballAgp extends ActivityGroup implements
		OnClickListener, OnTabChangeListener {

	private TabHost sportteryFootballTabHostMain;
	/** 继续选队按钮 */
	private Button btnSportteryFootballGoonChoose;
	// private ImageButton btnSportteryFootballAgpMenu;
	// /**筛选按钮*/
	// private ImageButton btnSportteryFootballAgpFilter;

	private Button hemai;
	// private TextView tvTitle;

	private static final String TAB_CHOOSE = "0";
	private static final String TAB_HEMAI = "1";
	private static final String TAB_LOTTERY_RECORD = "2";
	private static final String TAB_LOTTER_INFO = "3";
	private static final String TAB_INTRODACTION = "4";

	private Dialog menuDialog = null;

	private TextView tvTitle;

	private int CURRENT_TAB_NUM;
	private Bundle bundleSetCurrentTab;

	public static Handler handlerSportteryFootballAgp;
	public static final int IN_CHOOSE_VIEW = 10001;
	public static final int IN_LIST_VIEW = 10002;
	public static final int SHOW_FILTER = 10003;
	public static final int NO_FILTER = 10004;

	// 精彩足球开奖信息选择日期按钮所需数据
	/** ======================start================= */
	private int mYear;
	private int mMonth;
	private int mDay;
	private int currentYear;
	private int currentMonth;
	private int currentDay;
	private Handler handler;
	private static final int GET_SERVERTIME_SUCCEED = 10005;
	private static final int GET_SERVERTIME_FAILED = 10006;
	private static final int DATE_DIALOG_ID = 1;

	private boolean isStop = false;// 若获取失败，是否继续获取当前时间
	private ImageButton btnDateChoose;
	private boolean isExcute = false;// 是否获取过服务器时间

	private Dialog quitDialog;

	/** ======================end================= */
	private Button ibtnShowHelp;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sportteryfootball_agp);

		bundleSetCurrentTab = this.getIntent().getExtras();
		CURRENT_TAB_NUM = bundleSetCurrentTab.getInt("CURRENT_TAB_NUM");
		EDebug.o(this, "set currentTab " + CURRENT_TAB_NUM);
		initUI();
		handlerInit();

		initHandler();

	}

	private void handlerInit() {
		handlerSportteryFootballAgp = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				switch (msg.what) {
				case IN_CHOOSE_VIEW:
					tvTitle.setText("竞彩足球");
					ibtnShowHelp.setVisibility(View.VISIBLE);
					btnSportteryFootballGoonChoose.setVisibility(View.GONE);
					// btnSportteryFootballAgpFilter.setVisibility(View.VISIBLE);
					break;

				case IN_LIST_VIEW:
					tvTitle.setText("投注列表");
					ibtnShowHelp.setVisibility(View.GONE);
					btnSportteryFootballGoonChoose.setVisibility(View.VISIBLE);
					// EDebug.o("切换4次");
					// Message msg =
					// SportteryFootballChooseList.handlerChoosePage
					// .obtainMessage(SportteryFootballChooseList.DO_BACK_UPDATE,
					// null);
					// SportteryFootballChooseList.handlerChoosePage.sendMessage(msg);
					// ((Activity)
					// context).setContentView(chooseListPage.getView());
					break;

				case SHOW_FILTER:
					// btnSportteryFootballAgpFilter
					// .setImageResource(R.drawable.icon_pressed_pickteam_sx_42x48);
					break;

				case NO_FILTER:
					// btnSportteryFootballAgpFilter
					// .setImageResource(R.drawable.icon_default_pickteam_sx_33x40);
					break;
				default:
					break;
				}
			}
		};
	}

	private void initUI() {
		tabInit();
		ibtnShowHelp = (Button) findViewById(R.id.ibtnGameHelp);
		ibtnShowHelp.setOnClickListener(this);
		btnSportteryFootballGoonChoose = (Button) findViewById(R.id.sportteryfootballagp_btn_cancel_goon);
		btnSportteryFootballGoonChoose.setOnClickListener(this);
		// btnSportteryFootballAgpMenu = (ImageButton)
		// findViewById(R.id.sportteryfootballagp_btn_menu);
		// btnSportteryFootballAgpMenu.setOnClickListener(this);
		// btnSportteryFootballAgpFilter = (ImageButton)
		// findViewById(R.id.sportteryfootballagp_btn_filter);
		// btnSportteryFootballAgpFilter.setOnClickListener(this);

		hemai = (Button) findViewById(R.id.sportteryfootballagp_btn_hemai);
		hemai.setOnClickListener(this);

		btnDateChoose = (ImageButton) findViewById(R.id.sportteryfootball_agp_btn_dateChoose);
		btnDateChoose.setOnClickListener(this);
		tvTitle = (TextView) findViewById(R.id.sportteryfootballagp_tv_title);
		if (CURRENT_TAB_NUM == 0) {
			tvTitle.setText("竞彩足球");
		} else if (CURRENT_TAB_NUM == 1) {
			// btnSportteryFootballAgpFilter.setVisibility(View.GONE);
			tvTitle.setText("投注列表");
			ibtnShowHelp.setVisibility(View.GONE);
			btnSportteryFootballGoonChoose.setVisibility(View.VISIBLE);

			EDebug.o("切换1次");
		}

	}

	private void tabInit() {
		sportteryFootballTabHostMain = (TabHost) findViewById(R.id.sportteryfootballagp_tabhost_main);
		sportteryFootballTabHostMain.setup(SportteryFootballAgp.this
				.getLocalActivityManager());

		TabSpec ts0 = sportteryFootballTabHostMain.newTabSpec(TAB_CHOOSE);
		ts0.setIndicator("");
		ts0.setContent(new Intent(this, SportteryFootballChooseAct.class));
		sportteryFootballTabHostMain.addTab(ts0);

		TabSpec ts1 = sportteryFootballTabHostMain.newTabSpec(TAB_HEMAI);
		ts1.setIndicator("");
		ts1.setContent(new Intent(this, LoginAct.class));
		sportteryFootballTabHostMain.addTab(ts1);

		TabSpec ts2 = sportteryFootballTabHostMain
				.newTabSpec(TAB_LOTTERY_RECORD);
		ts2.setIndicator("");
		// ts2.setContent(new Intent(this, LotteryRecordFootballAct.class));
		ts2.setContent(new Intent(this, LotteryInfoListFootball.class));
		// .putExtra("lotid", Config.JINGCAIZUQIU));
		sportteryFootballTabHostMain.addTab(ts2);

		TabSpec ts3 = sportteryFootballTabHostMain.newTabSpec(TAB_LOTTER_INFO);
		ts3.setIndicator("");
		ts3.setContent(new Intent(this, LotteryInfoListFootball.class)
				.putExtra("lotid", Config.JINGCAIZUQIU));
		sportteryFootballTabHostMain.addTab(ts3);

		TabSpec ts4 = sportteryFootballTabHostMain.newTabSpec(TAB_INTRODACTION);
		ts4.setIndicator("");
		ts4.setContent(new Intent(this, SportteryFootbalHelp.class).putExtra(
				"lotid", Config.JINGCAIZUQIU));
		// ts4.setContent(new Intent(this, HelpAct.class).putExtra("url",
		// Config.SPORTTERYFOOTBALL_INTRODUCE_WEB_ADD).putExtra("title",
		// Config.NULLMARK).putExtra("havetitle", Config.NUM0));
		sportteryFootballTabHostMain.addTab(ts4);

		sportteryFootballTabHostMain.setCurrentTab(CURRENT_TAB_NUM);
		sportteryFootballTabHostMain.setOnTabChangedListener(this);
	}

	@Override
	public void onClick(View v) {

		Message msgRefresh = new Message();
		msgRefresh.what = Config.DO_REFRESH;

		switch (v.getId()) {

		case R.id.sportteryfootballagp_btn_hemai:
			// Intent sporthelpIntent = new Intent();
			// sporthelpIntent.setClass(this, SportteryFootbalHelp.class);
			// startActivity(sporthelpIntent);
			// startActivity(new Intent(SportteryFootballAgp.this,
			// SportteryFootbalHelp.class))
			SportteryFootballAgp.this.finish();
			Intent intent = new Intent();
			intent.setClass(SportteryFootballAgp.this, LotteryRecordAgp.class);
			// PersonalAct.flag = Language.FLAG_SIX;
			// HomeAct.flag = Language.FLAG_ONE;
			startActivity(intent);

			// showdialogPlayHelp();
			break;
		case R.id.sportteryfootballagp_btn_cancel:
			SportteryFootballAgp.this.finish();

			break;
		case R.id.sportteryfootballagp_btn_cancel_goon:
			showQuitDialog();

			/*
			 * sportteryFootballTabHostMain.setCurrentTab(0); Message message =
			 * SportteryFootballChooseList.handlerChoosePage
			 * .obtainMessage(SportteryFootballChooseList.DO_BACK_UPDATE, null);
			 * SportteryFootballChooseList
			 * .handlerChoosePage.sendMessage(message); // ((Activity)
			 * context).setContentView(chooseListPage.getView());
			 * 
			 * sportteryFootballTabHostMain.setCurrentTab(0); //
			 * menuDialog.dismiss(); EDebug.o("切换成功-----------------");
			 */
			Log.e("llllll", SportteryFootballAgp.this.getCurrentActivity()
					.getClass().toString());
			// ((SportteryFootballChooseAct) (SportteryFootballAgp.this
			// .getCurrentActivity())).clean();
			// m1.clean();
			// Intent intentToSportteryFootball = new Intent();
			//
			// Bundle bundleToSportteryFootbal = new Bundle();
			// bundleToSportteryFootbal.putInt("CURRENT_TAB_NUM", 0);
			// intentToSportteryFootball.putExtras(bundleToSportteryFootbal);
			// intentToSportteryFootball
			// .setClass(this, SportteryFootballAgp.class);
			// EDebug.o("=====================click to shuangseqiu choose");
			// startActivity(intentToSportteryFootball);
			// SportteryFootballAgp.this.finish();
			break;

		// case R.id.sportteryfootballagp_btn_menu:
		// setMenuDialog();
		// break;

		// case R.id.sportteryfootballagp_btn_filter:
		// Message msg = SportteryFootballChooseList.handlerChoosePage
		// .obtainMessage(SportteryFootballChooseList.DO_FILTER, null);
		// SportteryFootballChooseList.handlerChoosePage.sendMessage(msg);
		// break;

		case R.id.shuangseqiuagpdialogmenu_btn_choose:
			sportteryFootballTabHostMain.setCurrentTab(0);
			menuDialog.dismiss();
			break;

		case R.id.shuangseqiuagpdialogmenu_btn_hemai:
			// btnSportteryFootballAgpFilter.setVisibility(View.GONE);
			// SportteryFootballHemaiAct.showType = 0;
			sportteryFootballTabHostMain.setCurrentTab(1);
			menuDialog.dismiss();
			break;

		case R.id.shuangseqiuagpdialogmenu_btn_lotteryRecord:
			if (isLogin()) {
				// btnSportteryFootballAgpFilter.setVisibility(View.GONE);
				sportteryFootballTabHostMain.setCurrentTab(2);
				// LotteryRecordFootballAct.handlerGetFootballLotteryRecord.sendMessage(msgRefresh);
			} else {
				startActivity(new Intent(SportteryFootballAgp.this,
						LoginAct.class));
			}
			menuDialog.dismiss();
			break;

		case R.id.shuangseqiuagpdialogmenu_btn_lotteryInfo:
			// btnSportteryFootballAgpFilter.setVisibility(View.GONE);
			if (!isExcute) {
				// getCurrentServerTimeThread();
				isExcute = true;
			}
			sportteryFootballTabHostMain.setCurrentTab(3);
			menuDialog.dismiss();
			break;

		case R.id.shuangseqiuagpdialogmenu_btn_introduction:
			// btnSportteryFootballAgpFilter.setVisibility(View.GONE);
			sportteryFootballTabHostMain.setCurrentTab(4);
			menuDialog.dismiss();
			break;

		case R.id.shuangseqiuagp_dialog_menu_linear_bg:
			menuDialog.dismiss();
			break;

		case R.id.sportteryfootball_agp_btn_dateChoose:

			SportteryFootballAgp.this.showDialog(DATE_DIALOG_ID);

			break;
		case R.id.dialogquit_btn_submit:

			((SportteryFootballChooseAct) (SportteryFootballAgp.this
					.getCurrentActivity())).clean();
			quitDialog.dismiss();
			break;
		case R.id.dialogquit_btn_cancel:
			quitDialog.dismiss();

			break;
		case R.id.ibtnGameHelp:
			showdialogPlayHelp();
			break;

		default:

			break;
		}
	}

	private void showQuitDialog() {
		// TODO Auto-generated method stub
		quitDialog = new Dialog(this, R.style.dialog);
		quitDialog.getWindow().setContentView(R.layout.dialog_betcancel);

		// tvDialogMsg = (TextView) quitDialog.getWindow().findViewById(
		// R.id.dialogquit_tv_msg);
		// tvDialogMsg.setText(Language.MSG_QUITDIALOG);
		Button btnDialogcancel = (Button) quitDialog.getWindow().findViewById(
				R.id.dialogquit_btn_cancel);
		btnDialogcancel.setOnClickListener(this);
		Button btnDialogSubmit = (Button) quitDialog.getWindow().findViewById(
				R.id.dialogquit_btn_submit);
		btnDialogSubmit.setOnClickListener(this);

		quitDialog.show();
	}

	private boolean isLogin() {
		if (UserInfo.getUserInfo().getCk().length() > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public void onTabChanged(String tabId) {

		int index = Integer.valueOf(tabId);

		// 判断是否显示期号选择按钮、
		if (index == 3) {
			btnDateChoose.setVisibility(View.VISIBLE);
		} else {
			btnDateChoose.setVisibility(View.GONE);
		}

		switch (index) {
		case 0:
			if (((SportteryChooseActivity) sportteryFootballTabHostMain
					.getCurrentView().getContext()).getCurrentPageFlag() == 0) {
				tvTitle.setText("竞彩足球");
				ibtnShowHelp.setVisibility(View.VISIBLE);
				btnSportteryFootballGoonChoose.setVisibility(View.GONE);
				// btnSportteryFootballAgpFilter.setVisibility(View.VISIBLE);
			} else if (((SportteryChooseActivity) sportteryFootballTabHostMain
					.getCurrentView().getContext()).getCurrentPageFlag() == 1) {
				tvTitle.setText("投注列表");
				EDebug.o("切换2次");
				ibtnShowHelp.setVisibility(View.GONE);
				btnSportteryFootballGoonChoose.setVisibility(View.VISIBLE);
				// btnSportteryFootballAgpFilter.setVisibility(View.GONE);
			}
			break;

		case 1:
			tvTitle.setText("投注列表");
			ibtnShowHelp.setVisibility(View.GONE);
			btnSportteryFootballGoonChoose.setVisibility(View.VISIBLE);
			EDebug.o("切换3次");
			break;

		case 2:
			tvTitle.setText("让球胜平负购彩记录");
			break;

		case 3:
			tvTitle.setText("竞彩足球开奖信息");
			break;

		case 4:
			tvTitle.setText("竞彩足球胜平负玩法介绍");
			break;

		default:
			break;
		}

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_MENU) {
			// setMenuDialog();
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	@Override
	public boolean onTrackballEvent(MotionEvent event) {
		return true;
	}

	/** ======================start================= */

	// 获取本地当前日期
	private void getLocalDate() {
		final Calendar c = Calendar.getInstance();
		updateCurrentTime(c.get(Calendar.YEAR), c.get(Calendar.MONTH) + 1,
				c.get(Calendar.DAY_OF_MONTH));
		EDebug.o(this, currentYear + "-" + currentMonth + "-" + currentDay);
	}

	// 更新当前日期
	private void updateCurrentTime(int year, int month, int day) {
		EDebug.o(this, "更新当前日期" + year + "-" + month + "-" + day);
		currentYear = year;
		currentMonth = month;
		currentDay = day;

	}

	CustomDatePicker datePicker;

	@Override
	protected Dialog onCreateDialog(int id) {
		switch (id) {
		case DATE_DIALOG_ID:
			EDebug.o(this, "生成dialog" + currentYear + "-" + currentMonth + "-"
					+ currentDay);
			datePicker = new CustomDatePicker(this, mDateSetListener,
					currentYear, currentMonth - 1, currentDay);
			return datePicker;
		}
		return null;
	}

	@Override
	protected void onPrepareDialog(int id, Dialog dialog) {
		switch (id) {
		case DATE_DIALOG_ID:
			EDebug.o(this,
					"print by billy =>> onPrepareDialog 准备dialog current"
							+ currentYear + "-" + currentMonth + "-"
							+ currentDay);
			EDebug.o(this,
					"print by billy =>> onPrepareDialog 准备dialog changed"
							+ mYear + "-" + (mMonth + 1) + "-" + mDay);
			if (mYear == 0 || mMonth == 0 || mDay == 0) {
				((DatePickerDialog) dialog).updateDate(currentYear,
						currentMonth - 1, currentDay);
			} else {
				((DatePickerDialog) dialog).updateDate(mYear, mMonth, mDay);
			}
			EDebug.o(this, "date dialog width = "
					+ ((DatePickerDialog) dialog).getWindow()
							.getWindowManager().getDefaultDisplay().getWidth());
			EDebug.o(this, "date dialog heigth = "
					+ ((DatePickerDialog) dialog).getWindow()
							.getWindowManager().getDefaultDisplay().getHeight());
			break;
		}
	}

	// 向竞彩足球开奖信息发送日期
	private void sendDateInfo() {
		EDebug.o(this, mYear + "-" + mMonth + "-" + mDay);
		int temp_month = mMonth + 1;
		if (isDateEnable(mYear, temp_month, mDay)) {
			// Message msg = new Message();
			Hashtable<String, String> map = new Hashtable<String, String>();
			map.put("year", String.valueOf(mYear));
			if (temp_month >= 10) {
				map.put("month", String.valueOf(temp_month));
			} else {
				map.put("month", "0" + String.valueOf(temp_month));
			}
			if (mDay >= 10) {
				map.put("day", String.valueOf(mDay));
			} else {
				map.put("day", "0" + String.valueOf(mDay));
			}
			EDebug.o(
					this,
					map.get("year") + "-" + map.get("month") + "-"
							+ map.get("day"));
			// msg =
			// LotteryInfoListFootball.handler.obtainMessage(LotteryInfoListFootball.DATE_CHANGED,
			// map);
			// LotteryInfoListFootball.handler.sendMessage(msg);
			// } else {
			// ViewerUtil.showTipDialog(SportteryFootballAgp.this,
			// getResources()
			// .getString(R.string.date_error), false);
			Toast.makeText(SportteryFootballAgp.this,
					getResources().getString(R.string.date_error), 500).show();
		}
	}

	// 判断所选日期是不是超出范围
	private boolean isDateEnable(int year, int month, int day) {

		String[] strStartingDate = Config.FOOTBALL_LOTTERYINFO_STARTINGDATE
				.split("-");

		int startingYear = Integer.valueOf(strStartingDate[0]);
		int startingMonth = Integer.valueOf(strStartingDate[1]);
		int startingDay = Integer.valueOf(strStartingDate[2]);

		if (year > currentYear || year < startingYear) {
			EDebug.o(this, "所选年份超出范围" + year + "===" + month + "===" + day
					+ "错误");
			return false;
		} else if (year == startingYear) {
			if (month < startingMonth) {
				EDebug.o(this, "所选年份为初始年份时,所选月份小于初始月份" + year + "===" + month
						+ "===" + day + "错误");
				return false;
			} else if (month == startingMonth) {
				if (day < startingDay) {
					EDebug.o(this, "所选年份为初始年份,所选月份为始月份,所选日小于初始日" + year + "==="
							+ month + "===" + day + "错误");
					return false;
				} else {
					EDebug.o(this, "所选年份为初始年份,所选月份为始月份,所选日大于等于初始日" + year
							+ "===" + month + "===" + day + "正确");
					return true;
				}
			} else {
				EDebug.o(this, "所选年份为初始年份,所选月份大于初始月份" + year + "===" + month
						+ "===" + day + "正确");
				return true;
			}
		} else if (year == currentYear) {
			if (month > currentMonth) {
				EDebug.o(this, "所选年份为当前年份,所选月份大于当前月份" + year + "===" + month
						+ "===" + day + "错误");
				return false;
			} else if (month == currentMonth) {
				if (day >= currentDay) {
					EDebug.o(this, "所选年份为当前年份,所选月份等于当前月份,所选日大于等于当前日" + year
							+ "===" + month + "===" + day + "错误");
					return false;
				} else {
					EDebug.o(this, "所选年份为当前年份,所选月份等于当前月份,所选日小于当前日" + year
							+ "===" + month + "===" + day + "正确");
					return true;
				}
			} else {
				EDebug.o(this, "所选年份为当前年份,所选月份小于当前月份" + year + "===" + month
						+ "===" + day + "正确");
				return true;
			}
		} else {
			EDebug.o(this, "所选年份在区间范围内" + year + "===" + month + "===" + day
					+ "正确");
			return true;
		}
	}

	// 点击设置事件响应
	private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {

		public void onDateSet(DatePicker view, int year, int monthOfYear,
				int dayOfMonth) {
			// mYear = year;
			// mMonth = monthOfYear;
			// mDay = dayOfMonth;
			EDebug.o(this, "print by billy =>> onDateSet " + year + "-"
					+ monthOfYear + "-" + dayOfMonth);
			sendDateInfo();
		}

	};

	// 重写DatePickerDialog，改变按钮文字
	private class CustomDatePicker extends DatePickerDialog {

		public CustomDatePicker(Context context, OnDateSetListener callBack,
				int year, int monthOfYear, int dayOfMonth) {
			super(context, callBack, year, monthOfYear, dayOfMonth);
			setButton("确定", this);
			setButton2("取消", (OnClickListener) null);
		}

		@Override
		public void onDateChanged(DatePicker view, int year, int month, int day) {
			super.onDateChanged(view, year, month, day);
			mYear = year;
			mMonth = month;
			mDay = day;
			EDebug.o(this, "print by billy =>> onDateChanged " + year + "-"
					+ (month + 1) + "-" + day);
		}
	}

	private void initHandler() {
		handler = new Handler() {

			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);
				switch (msg.what) {
				case GET_SERVERTIME_SUCCEED:

					EDebug.o(SportteryFootballAgp.this, "get time succeed");
					// ServerCurrentTimeInfo timeInfo =
					// timeCommunicater.getCurrentServerTime();
					// String[] strDate = timeInfo.getServerDate().split("-");
					// updateCurrentTime(Integer.valueOf(strDate[0]),
					// Integer.valueOf(strDate[1]),
					// Integer.valueOf(strDate[2]));
					isStop = false;

					break;

				case GET_SERVERTIME_FAILED:

					// 暂用本地时间,3秒后重新获取服务器时间
					EDebug.o(SportteryFootballAgp.this,
							"get time succeed failed == delay");
					getLocalDate();
					delayThread();

					break;

				case DELAY_FINISH:

					EDebug.o(SportteryFootballAgp.this, "get time again");
					if (isStop) {
						// getCurrentServerTimeThread();
					}

					break;

				default:
					break;
				}
			}
		};
	}

	// 获取当前服务器时间
	/*
	 * private void getCurrentServerTimeThread() { new Thread() {
	 * 
	 * @Override public void run() { super.run(); if (timeCommunicater == null)
	 * { timeCommunicater = new GetServerTimeCommunicater(handler); } try {
	 * boolean isSucceed = timeCommunicater.isGetServerTimeSucceed(); if
	 * (isSucceed) { Message msg = handler.obtainMessage(GET_SERVERTIME_SUCCEED,
	 * null); handler.sendMessage(msg); } else { Message msg =
	 * handler.obtainMessage(GET_SERVERTIME_FAILED, null);
	 * handler.sendMessage(msg); } } catch (Exception e) { Message msg =
	 * handler.obtainMessage(Config.CONNECTION_FAIL, null);
	 * handler.sendMessage(msg); } } }.start(); }
	 */

	// 延迟3秒线程
	private static final int DELAY_FINISH = 10003;
	private Dialog playHelpDialog;

	private void delayThread() {
		new Thread() {
			@Override
			public void run() {
				super.run();
				try {
					sleep(3000);
					EDebug.o(SportteryFootballAgp.this, "delay 3");
					Message msg = new Message();
					msg = handler.obtainMessage(DELAY_FINISH, null);
					handler.sendMessage(msg);
				} catch (Exception e) {

				}
			}
		}.start();
	}

	private void showdialogPlayHelp() {

		if (playHelpDialog == null) {
			playHelpDialog = new Dialog(SportteryFootballAgp.this,
					R.style.dialogNoFloating);
			playHelpDialog.getWindow().setContentView(R.layout.sporttoryhelp);
			Button btnFilterCancel = (Button) playHelpDialog
					.findViewById(R.id.withdrawal_tip_act_btn_goBack);
			btnFilterCancel.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					playHelpDialog.dismiss();
				}
			});
		}
		playHelpDialog.show();

	}

	/** ======================start================= */

}
